Commercial software development is a maturing discipline, which has historically been characterized by divergent approaches to design, coding, testing, and maintenance. Extreme programming, one of several emerging, so-called “agile methodologies,” attempts to unify the software development cycle into a holistic process to improve code quality and product viability, such as described in K. Beck, “Extreme Programming Explained: Embrace Change,” Addison-Wesley (2000), the disclosure of which is incorporated by reference. Extreme programming is practiced through simple design, small releases, metaphors, testing, refactoring, pair programming, and continuous integration.
Refactoring is an inherent part of extreme programming and has been adopted to facilitate the process of adding features to existing program code. Refactoring, however, is not exclusive to extreme programming and can be applied to other software development methodologies. Refactoring is defined as the process of changing software such that the changes do not alter the external behavior of the code, yet improve the internal code structure. As a result, refactoring improves code design after the code has been written by removing duplication, improving communication, simplifying structure, and adding flexibility.
Testing is also an inherent part of extreme programming, which divides testing into two categories. First, programmer or unit tests are written and maintained as part of the development activity in the same programming language as the code. Unit tests are integrated at the class level, preferably independently of each other and test the classes to verify complicated functionality and unusual circumstances. Unit tests also document code by explicitly indicating what results should be expected for typical cases. Second, user or acceptance tests evaluate the functionality of an entire system, generally as specified by a customer or end user. Acceptance are typically written in a scripting language or in the same programming language as the code to check the overall functionality of the program by treating the code as a black box and omitting specific knowledge of system internals. Acceptance tests touch at application programming and graphical user interfaces to apply domain-specific data. When properly written, unit tests and acceptance tests can form comprehensive test suites that can dynamically verify program correctness at runtime. As well, either unit tests or acceptance tests can, by themselves, be considered comprehensive when each point of functionality has a set of covering tests, which ensure correct functioning and show some resistance to easily foreseen faults.
In contrast, refactoring is static activity that is conventionally applied to code as a structured, yet subjective methodology. In the general case, refactoring is as creative a process as the development of original program code. The critical points that distinguish general programming and refactoring are that: (1) the needed functionality is not changed as the result of the software changing, and (2) the software is improved in some way, such as being smaller, simpler, or made amenable to a subsequent development. Although refactoring can be applied to all forms of structured program code, refactoring is most effectively applied to object oriented code, preferably within the context of a testing framework. Refactoring can involve selecting and restructuring code according to well-accepted refactoring rules, such as listed in the catalogue of refactoring rules described in M. Fowler, “Refactoring Improving The Design Of Existing Code,” Chs. 6-12, Addison-Wesley (1999), the disclosure of which is incorporated by reference. The validity of refactoring rules can be determined through testing or semantic proofs, which can also be subject to assumptions regarding the code.
Ideally, refactoring should be applied as a continuous process integral to the overall software development cycle. Identifying opportunities within code to apply refactoring is nevertheless subjective and relatively ad hoc, involving visual inspection and manual rewritings of code. Moreover, the set of refactoring rules chosen tends to be highly dependent upon the experience and preferences of the developers involved. Consequently, automated refactoring methodologies generally are conservative and apply only to those refactorings, which can be proven semantically correct, or can be proven semantically correct after making certain assumptions. Thus, the code is only evaluated within the context of literal class definitions and runtime constraints and other factors placed on the code in the dynamic environment are ignored during refactoring selection. In addition, automated refactoring methodologies require human initiation, often through the use of an integrated development environment. As a result, code refactored through automated methodologies often remains suitable for further refactoring.
Therefore, there is a need for an approach to providing automated identification of a range of useable refactorings for code determined within a static and dynamic context. Preferably, such an approach would allow a wider range of refactorings than only those refactorings proven semantically correct and would apply comprehensive testing to validate the program correctness.